package com.itdao.dp.strategy.duck;

import com.itdao.dp.strategy.duck.behavior.quack.impl.GaGaQuackBehavior;
import com.itdao.dp.strategy.duck.holder.Duck;
import com.itdao.dp.strategy.duck.holder.PekingDuck;
import com.itdao.dp.strategy.duck.holder.ToyDuck;
import com.itdao.dp.strategy.duck.holder.WildDuck;

import java.util.HashMap;
import java.util.Map;

public class AppTest {
    public static Map<String, Duck> duckMap = new HashMap<String, Duck>() {
        {
            put(PekingDuck.class.getName(), new PekingDuck());
            put(WildDuck.class.getName(), new WildDuck());
            put(ToyDuck.class.getName(), new ToyDuck());
        }
    };

    public static void main(String[] args) {
        Duck wildDuck = duckMap.get(WildDuck.class.getName());
        wildDuck.display();
        wildDuck.fly();
        wildDuck.quack();
        wildDuck.swim();

        System.out.println("--------------------");

        Duck toyDuck = duckMap.get(ToyDuck.class.getName());
        toyDuck.display();
        toyDuck.fly();
        toyDuck.quack();
        toyDuck.swim();

        toyDuck.setQuackBehavior(new GaGaQuackBehavior());
        System.out.println(">>>>>>>改变玩具叫的行为:");
        toyDuck.quack();

        System.out.println("--------------------");

        Duck pekingDuck = duckMap.get(PekingDuck.class.getName());
        pekingDuck.display();
        pekingDuck.fly();
        pekingDuck.quack();
        pekingDuck.swim();
        // 输出结果：
        /**
         * 我是野鸭~~
         * 飞翔技术高超~~
         * 嘎嘎叫~~
         * 游泳技术高超~~
         * --------------------
         * 我是玩具鸭~~
         * 不会飞翔~~
         * 不会叫~~
         * 不会游泳~~
         * >>>>>>>改变玩具叫的行为:
         * 嘎嘎叫~~
         * --------------------
         * 我是北京鸭~~
         * 飞翔技术一般~~
         * 咯咯叫~~
         * 游泳技术一般~~
         */
    }
}
